#include<iostream>
#include<string>
using namespace std;
class Title
{
    private:
        string m_title;
        int m_salary;
    public:
        ~Title();
        string get_title()
        {
            return m_title;
        }
        void set_title(string title)
        {
            m_title="title:"+title;
        }
        int get_salary()
        {
            return m_salary;
        }
        void set_salary(int salary)
        {
            m_salary=salary;
        }
};
class Manager:public Title{
    private:
        static Manager* instance;
        Manager(){};
        string m_title;
        int m_salary;
    public:
        static Manager* getInstance(){
            if(instance==NULL){
                instance=new Manager();
            }
            return instance;
        }
};
class HR:public Title{
    private:
        static HR* instance;
        HR(){};
        string m_title;
        int m_salary;
    public:
        static HR* getInstance(){
            if(instance==NULL){
                instance=new HR();
            }
            return instance;
        }
};
class Financial:public Title{
    private:
        static Financial* instance;
        Financial(){};
        string m_title;
        int m_salary;
    public:
        static Financial* getInstance(){
            if(instance==NULL){
                instance=new Financial();
            }
            return instance;
        }
};
class Sales:public Title{
    private:
        static Sales* instance;
        Sales(){};
        string m_title;
        int m_salary;
    public:
        static Sales* getInstance(){
            if(instance==NULL){
                instance=new Sales();
            }
            return instance;
        }
};
class Executive:public Title{
    private:
        static Executive* instance;
        Executive(){};
        string m_title;
        int m_salary;
    public:
        static Executive* getInstance(){
            if(instance==NULL){
                instance=new Executive();
            }
            return instance;
        }
};
Manager* Manager::instance=NULL;
HR* HR::instance=NULL;
Financial* Financial::instance=NULL;
Sales* Sales::instance=NULL;
Executive* Executive::instance=NULL;
class employee
{
    private:
    string m_eid;
    string m_name;
    string m_gender;
    string m_dob;
    string m_doe;
    string m_unit;
    Title *title1;
    public:
    employee(string eid,string name,string gender,string dob,string doe,string unit,string title,int salary)
    {
        m_eid="eid:"+eid;
        m_name="name:"+name;
        m_gender="gender:"+gender;
        m_dob="dob:"+dob;
        m_doe="doe:"+doe;
        m_unit="unit:"+unit;
        if(title.compare("Manager")==0)
            title1=Manager::getInstance();
        if(title.compare("HR")==0)
            title1=HR::getInstance();
        if(title.compare("Financial")==0)
            title1=Financial::getInstance();
        if(title.compare("Sales")==0)
            title1=Sales::getInstance();
        if(title.compare("Executive")==0)
            title1=Executive::getInstance();
        title1->set_title(title);
        title1->set_salary(salary);
    }
    employee(char*pBuff)
    {
        int m=0;
        int c=0;
        string str=pBuff;
        string title;
        int len=str.length();
        for(int i=0;i<len;i++)
        {
            while(pBuff[i]!=' '&&pBuff[i]!='\0')
            {
               if(pBuff[i]==':')
               {
                   m=i+1;
               }
               i++;
            }
            if(c==0) m_eid="eid:"+str.substr(m,i-m);
            if(c==1) m_name="name:"+str.substr(m,i-m);
            if(c==2) m_gender="gender:"+str.substr(m,i-m);
            if(c==3) m_dob="dob:"+str.substr(m,i-m);
            if(c==4) m_doe="doe:"+str.substr(m,i-m);
            if(c==5) m_unit="unit:"+str.substr(m,i-m);
            if(c==6){
                if(str.substr(m,i-m).compare("Manager")==0)
                    title1=Manager::getInstance();
                if(str.substr(m,i-m).compare("HR")==0)
                    title1=HR::getInstance();
                if(str.substr(m,i-m).compare("Financial")==0)
                    title1=Financial::getInstance();
                if(str.substr(m,i-m).compare("Sales")==0)
                    title1=Sales::getInstance();
                if(str.substr(m,i-m).compare("Executive")==0)
                    title1=Executive::getInstance();
                title1->set_title(str.substr(m,i-m).c_str());
            }
            if(c==7) title1->set_salary(atoi(str.substr(m,i-m).c_str()));
            c++;
        }
    }
    ~employee();
    void print()
        {
            cout<<m_eid<<" ";
            cout<<m_name<<" ";
            cout<<m_gender<<" ";
            cout<<m_dob<<" ";
            cout<<m_doe<<" ";
            cout<<m_unit<<" ";
            cout<<title1->get_title()<<" ";
            cout<<title1->get_salary();
            cout<<"\n";
        }
     void set_eid(string eid)
    {
        m_eid=eid;
    }
    string get_eid_num(){
        int i=m_eid.find(":");
        return m_eid.substr(i+1);
    }
    string get_eid()
    {
        return m_eid;
    }
    void set_name(string name)
    {
        m_name=name;
    }
    string get_name()
    {
        return m_name;
    }
    void set_gender(string gender)
    {
        m_gender=gender;
    }
    string get_gender()
    {
        return m_gender;
    }
    void set_dob(string dob)
    {
        m_dob=dob;
    }
    string get_dob()
    {
        return m_dob;
    }
    void set_doe(string doe)
    {
        m_doe=doe;
    }
    string get_doe()
    {
        return m_doe;
    }
    void set_unit(string unit)
    {
        m_unit=unit;
    }
    string get_unit()
    {
        return m_unit;
    }
    
    string get_title(){
        return title1->get_title();
    }
    void set_title(string title){
        if(title.compare("Manager")==0)
            title1=Manager::getInstance();
        if(title.compare("HR")==0)
            title1=HR::getInstance();
        if(title.compare("Financial")==0)
            title1=Financial::getInstance();
        if(title.compare("Sales")==0)
            title1=Sales::getInstance();
        if(title.compare("Executive")==0)
            title1=Executive::getInstance();
        title1->set_title(title.c_str());
    }
    int get_salary(){
        return title1->get_salary();
    }
    void set_salary(int salary){
        title1->set_salary(salary);
    }

};

/*
测试数据
001 lihua man 2000/1/1 2020/1/1 HumanResourcesDepartment Manager 500
002 lsdf woman 2000/1/1 2020/1/1 HumanResourcesDepartment Manager 500
003 jisdf man 2000/1/1 2020/1/1 FinanceDepartment HR 400
004 dsaf woman 2000/1/1 2020/1/1 FinanceDepartment HR 400
eid:001 name:li gender:man dob:sad doe:asd unit:HumanResourcesDepartment title:Manager salary:500
eid:002 name:sdf gender:woman dob:sad doe:asd unit:FinanceDepartment title:HR salary:300
*/